//
//  ViewController.m
//  UI18_SQLite
//
//  Created by dllo on 16/8/8.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "ViewController.h"
#import "SQLiteDataBaseManager.h"
#import "Student.h"
@interface ViewController ()

@property (nonatomic, strong) SQLiteDataBaseManager *dataBaseManager;

@end

@implementation ViewController
- (IBAction)openSQLiteButton:(id)sender {
    [_dataBaseManager openSQLite3];
    // 注意: 使用SQLite需要引入sqlite3.0.tdb
    // sqlite3.tdb 和sqlite3.0.tdb区别
    // sqlite3.0.tdb 是sqlite3.tdb的提审文件 放置误删
}

- (IBAction)closeSQLite:(id)sender {
    [_dataBaseManager closeSQLite3];
}
- (IBAction)createTable:(id)sender {
    [_dataBaseManager createTable];
}
- (IBAction)insertStu:(id)sender {
    Student *stu = [[Student alloc] init];
    stu.stu_id = 17;
    stu.stu_name = @"Andy";
    [_dataBaseManager insertStu:stu];
}

- (IBAction)deleteStu:(id)sender {
    Student *stu = [[Student alloc] init];
    stu.stu_id = 17;
    stu.stu_name = @"Andy";
//    [_dataBaseManager deleteStu:stu];
    [_dataBaseManager deleteAll];
}

- (IBAction)update:(id)sender {
[_dataBaseManager updateOldName:@"Andy" newName:@"Mary"];
}

- (IBAction)selectAll:(id)sender {
    NSArray *array = [_dataBaseManager selectAll];
    NSLog(@"%@", array);
}




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _dataBaseManager = [SQLiteDataBaseManager sharedManager];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
